<%@ WebHandler Language="C#" Class="Search_CS" %>

using System;
using System.Web;
using System.Data.OleDb;
using System.Configuration;
using System.Text;
 
public class Search_CS : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        string prefixText = context.Request.QueryString["q"];
        string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + @"D:\HCMC_Service_Search_DB_Intergrated_.accdb" + ";Persist Security Info=False;";
		//new dataProvider().getStrCon();
        using (OleDbConnection conn = new OleDbConnection(strCon))
        {
            using (OleDbCommand cmd = new OleDbCommand())
            {
                cmd.CommandText = "select distinct DICHVU.MaDichVu, DICHVU.TenDichVu from TUKHOADICHVU, DICHVU where " +
                "TUKHOADICHVU.MaDichVu = DICHVU.MaDichVu and TUKHOADICHVU.TuKhoaDichVu like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", prefixText);
                cmd.Connection = conn;
                StringBuilder sb = new StringBuilder();
                conn.Open();
                using (OleDbDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        sb.Append(sdr["TenDichVu"])
                            .Append(Environment.NewLine);
                    }
                }
                conn.Close();
                context.Response.Write(sb.ToString());
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
}